You need R, RStudio, and some packages to get started. If you are completely new, I recommend resources from RLadies Sydney (BasicBasics and CleanItUp units are must-read).
In R, Working with tabular data using dplyr package is straightforward, |>or%>% pipe operators and these functions: mutate, select, filter and group_by along with 4 types of join should get you far.
The most popular package to work with spatial data in R is sf. An sf object extends regular tabular data frames to include a geometry column, which contains the spatial information. Thus, a simple explanation on how to read shapefiles with sf should be enough to get you started. Then, those mentioned dplyr functions will come in handy.
Motivation
To build maps in R, the two most popular packages are mapview and leaflet. For this report, I chose leaflet due to its flexibility and customizability.
Here’s the reasoning behind my choice and map design:
To show transportation hubs and major roads → Map tiles
To display warehouse locations with details → Markers with popups
To distinguish warehouse sizes → Marker size
To indicate warehouse type (3PL vs. in-house) → Marker color
To compare pre- and post-COVID landscapes → Two separate layers: before and after
To provide population context → Sub-layer of population density dots (since this is not the main focus)
Execution
1. Preparing data
Fullfillment Centers data
Data on fulfillment centers in Greater Melbourne was collected through manual searches on Google Maps, company website visits, news articles, and LinkedIn posts for 8 piece of information:
Name;
Address;
Since (the year the warehouse was established).
Type (in-house or 3PL);
Area (size of the warehouse, categorized as Small, Medium, Large);
Note (any additional information about the warehouse).
lat: (latitude coordinate of address);
lon (longitude coordinate of address);
lon and lat were obtained using the geocode function which retrieves latitude and longitude based on the address. Data is then turned into a sf object using sf::st_as_sf(coords = c("lon", "lat")
Base Map Tiles "OpenStreetMap" was used as the base tile. You can explore more tile options by changing the provider name in addProviderTiles().
2
Initial Map View fitBounds() sets the initial view using the bounding box of Greater Melbourne.
3
Warehouse Markers addCircleMarkers() adds two sets of warehouse markers (before and after COVID), customized by: popup for details on click, color for warehouse type (e.g., 3PL vs. in-house), radius for warehouse size
4
LegendaddLegend() displays a legend for warehouse types.
5
Population Density Key addControl() adds a toggleable key explaining the population density dots. It appears only when the corresponding layer is active.
6
Layer Control Panel addLayersControl() enables toggling between: Pre-COVID warehouses, Post-COVID warehouses, Population density dots
7
Population Density Dots addGlPoints() from the leafgl package is used to efficiently render thousands of population dots, providing better performance than addCircleMarkers() for large datasets.